package org.bees.cms.web.util.velocity.renderer;

import java.io.Serializable;

import net.sf.json.JSONObject;

import org.bees.cms.web.util.Beans;

public class RadioRenderer extends AbstractRenderer {
	private String name;

	@Override
	public void initialize(JSONObject json) throws Exception {
		super.initialize(json);
		name = json == null ? name : json.containsKey("name") ? json.getString("name") : name;
	}

	@Override
	public String render(Serializable t) throws Exception {
		return "<input id='" + id + "' class='" + clazz + "' style='" + style + "' type='radio' name='" + name + "' value='" + Beans.getString(t, property) + "' />";
	}

	@Override
	public void destroy() throws Exception {
		super.destroy();
		name = null;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}
